<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <!-- 模拟随机发放水果功能，水果品种固定，每次之发放一种并输出您获得的水果是XX
var fruits = ["苹果" ,"香蕉","梨子","西瓜","火龙果","芒果","荔枝"]; -->
</head>
<body>
    <button onclick="fru()">点我获得水果</button>
    <script>
        var fruits = ["苹果" ,"香蕉","梨子","西瓜","火龙果","芒果","荔枝"];
        function fru(){
            var a = Math.floor(Math.random()*7);
            document.write("您获得的水果是"+ fruits[a]);
        }
    </script>
</body>
</html>